$(function(){
     /* web */
     if (navigator.userAgent.match(/iPhone|iPod|iPad|Android|Windows CE|BlackBerry|Symbian|Windows Phone|webOS|Opera Mini|Opera Mobi|POLARIS|IEMobile|lgtelecom|nokia|SonyEricsson/i) == null && navigator.userAgent.match(/LG|SAMSUNG|Samsung/) == null) {
        $("#non-flash-broadcast .alterText").hide();
        $("#non-flash-broadcast").css({"display":"none"});
        $(".group_Broadcast_Flash").show();
        $("#tablet-broadcast").hide();

        // non flash
        $(function(){
            var playerVersion = swfobject.getFlashPlayerVersion();
            if (playerVersion.major == 0) {
                $(".group_Broadcast_Flash").hide();
                $("#tablet-broadcast").hide();
                $("#non-flash-broadcast .alterText").show();
                $("#non-flash-broadcast").css({"display":"block"});
            }
        });

     }
     /* mobile */
     else{
         $("#non-flash-broadcast .alterText").remove();
         $("#non-flash-broadcast").css({"margin-bottom":"0"});
         $(".group_Broadcast_Flash").remove();
         $("#tablet-broadcast").show();
         $("#header").animate({"left":"-160px"});
         $("#footer").animate({"left":"-160px"});
         $("h2").animate({"left":"30px"});
         $(".group_contents").animate({"left":"-160px"});
         $(".open").hide();
         $("#btn-top").hide();
         $("html").css({"overflow-x":"hidden"});
         $("body").css({"overflow-x":"hidden"});
         $("body").css({"background":"#35383d"});
         $(".close").show();
         $("#tablet-broadcastView").show();
         $(".vod").remove();
         $("#container > div").removeClass("scroll-pane");
         $("#calendar").css({"margin-left":"100px"});
         }
     });

/* layer */
$(document).ready(function() {
    if ( $(".photo_layOpen").length ) fe_layPop2();
});

$(window).load(function(){
/* layer height */
    if ( $(".photo_layer").length ) fe_asideHeight();
});

/* layer height */
function fe_asideHeight(){
    $(".photo_layer").height( $("#wrap").height() + "px");
}
/* layer */
function fe_layPop2(){

    function wrapWindowByMask(){
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();
        var layerHeight = $(".photo_layPop > div").height();
        var layerWidth = $(".photo_layPop > div").width();
        $(".photo_layer").css({"width":maskWidth,"height":maskHeight, "display": "block"});
        $(".photo_layPop").css({"margin-top": "-" + layerHeight/2 + "px", "margin-left" : "-" + layerWidth/2 + "px"});
    }
    $(".photo_layOpen").click(function(e){
        //$(".jspPane").css({"position":"static"});
        e.preventDefault();
        wrapWindowByMask();
    });
    $(".photo_mask").click(function (e) {
        e.preventDefault();
        $("#footer").css({"z-index":"9990"});
        $(".photo_layer").css("display","none");
        $(".photo_layer02").css("display","none");
        //$(".jspPane").css({"position":"absolute"});
    });
    $(".btnClose > a > img").click(function () {
        $("#footer").css({"z-index":"9990"});
        $(".photo_layer").css("display","none");
        //$(".jspPane").css({"position":"absolute"});
    });

    //그룹방송 편성표 리스트
    var day = $(".scheduleTable td a.on");
    var dayclose = $(".close_btn");
    var List = $(".schedule_Daylist");
    var List02 = $(".schedule_Daylist02");

    $(day).click(function(){
        $(List).hide();
        $(List02).hide();
        $(this).parent().parent().children(List).show();

        //$(List).toggle();
    });
    $(dayclose).click(function(){
        $(List).hide();
        $(List02).hide();
    });

    $(".schedule_Daylist_wrap a").click(function(){
        resizeFrame (".schedule_Daylist_scroll", ".schedule_Daylist02_scroll");
    });
}

/* layer */
$(document).ready(function() {
    if ( $("#Join").length ) join_layPop();
});

$(window).load(function(){
/* layer height */
    if ( $(".join_layer").length ) fe_asideHeight2();
});

/* layer height */
function fe_asideHeight2(){
    $(".join_layer").height( $("#wrap").height() + "px");
}
/* layer */
function join_layPop(){

    function wrapWindowByMask2(){
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();
        var layerHeight = $(".join_layPop > div").height();
        var layerWidth = $(".join_layPop > div").width();
        $(".join_layer").css({"width":maskWidth,"height":maskHeight, "display": "block"});
        $(".join_layPop").css({"margin-top": "-" + layerHeight/2 + "px", "margin-left" : "-" + layerWidth/2 + "px"});
    }
    $("#Join").click(function(e){
        //$(".jspPane").css({"position":"static"});
        e.preventDefault();
        wrapWindowByMask2();
    });
    $(".photo_mask").click(function (e) {
        e.preventDefault();
        $("#footer").css({"z-index":"9990"});
        $(".join_layer").css("display","none");

        //$(".jspPane").css({"position":"absolute"});
    });
    $(".request_btnClose > a > img").click(function () {
        $("#footer").css({"z-index":"9990"});
        $(".join_layer").css("display","none");
        $(".jspPane").css({"position":"absolute"});
    });

}

/* container height */
    $(document).ready(function(){
        var wH = $(window).height();
        $(".scroll-pane").css({'height':wH + 'px'});
    });
    var delay = (function(){
         var timer = 0;
         return function(callback, ms){
            clearTimeout (timer);
            timer = setTimeout(callback, ms);
         };
        })();
    function resizeFrame () {
            var scrbarW = $(".scroll-pane");
            $(scrbarW).jScrollPane();
    }
    $(window).resize(function () {
        var wH = $(window).height();;
        $(".scroll-pane").css({'height':wH + 'px'});
    });

    $(window).load(function(){
        var ctn = $("#container");
        var gnb = $("#header");
        var scrbarW = $(".scroll-pane");
        
        $(ctn).hover(
        function(){$("#container .jspVerticalBar").clearQueue().show();},
        function(){$("#container .jspVerticalBar").clearQueue().hide();}
        );
        $(gnb).hover(
        function(){$("#header .jspVerticalBar").clearQueue().show();},
        function(){$("#header .jspVerticalBar").clearQueue().hide();}
        );
        $(scrbarW).jScrollPane();
    });
    $(window).resize(function () {
        resizeFrame();
    });


    function pen(){
            //$(".menu_btn").animate({"left":"160px"});
            $("#header").animate({"left":"-160px"});
            $("#footer").animate({"left":"-160px"});
            $("h2").animate({"left":"30px"});
            $(".group_contents").animate({"left":"-160px"});
            $(".open").hide();
            $(".close").show();
    }
    function lose(){
            //$(".menu_btn").animate({"left":"320px"});
            $("#header").animate({"left":"0"});
            $("#footer").animate({"left":"15px"});
            $("h2").animate({"left":"194px"});
            $(".group_contents").animate({"left":"0"});
            $(".open").show();
            $(".close").hide();
    }

    $(document).ready(function(){
    var vodBg = $(".group_Broadcast_List ul li");
        $(vodBg).hover(
        function () {
            $(this).addClass("on");
        },
        function () {
            $(this).removeClass("on");
        }
    );

    /* gnb */
        var etcIcon = $(".etc ul li");
        $(etcIcon).hover(
        function () {$(this).addClass("on");},
        function () {$(this).removeClass("on");}
        );
    });
    $(document).ready(function(){
    var vodBg = $(".group_Broadcast_List ul li");
        $(vodBg).hover(
        function () {
    $(this).addClass("on");
     },
        function () {
    $(this).removeClass("on");
     }
    );

    var newsTab = $(".group_Broadcast_List_Tab ul li");
    $(newsTab).click(function(){
        $(newsTab).removeClass("on");
        $(newsTab).eq($(this).index()).addClass("on");
    });

});


$(document).ready(function(){
    /* layer */
    if ( $(".relation_layOpen").length ) fe_layPop();
});

$(window).load(function(){
    /* layer height */
    if ( $(".relation_layer").length ) fe_maskHeight();
});
/* layer height */
function fe_maskHeight(){
    $(".relation_layer").height( $("#wrap").height() + "px");
}
/* layer */
function fe_layPop(){
    function wrapWindowByMask(){
        var maskHeight = $(document).height();
        var maskWidth = $(document).width();
        $(".relation_layer").css({"width":maskWidth,"height":maskHeight}).show();
        var layerHeight = $(".relation_layPop > div").height();
        var layerWidth = $(".relation_layPop > div").width();
        var left = ( $(window).scrollLeft() + ($(window).width() - layerWidth) / 2 );
        var top = ( $(window).scrollTop() + ($(window).height() - layerHeight) / 2 );
        $(".relation_layer .relation_mask").css({"display" : "block"});
//        $(".relation_layPop").css({"top": top + "px", "left" : left + "px"}).show();
    }
    $(".relation_layOpen").click(function(e){
        e.preventDefault();
        wrapWindowByMask();
    });
    $(".relation_mask").click(function (e) {
        e.preventDefault();
        $(".relation_layer").hide();
    });
    $(".request_btnClose > a > img").click(function () {
        $(".relation_layer").css("display","none");
        $(".jspPane").css({"position":"absolute"});
    });
}

//google code
var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-35880241-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
